/**
 * Copyright (c) 2009 eelpo.com
 * All rights reserved.
 */
package com.eelpo.cmmp.uac.dao.vo.enumed;

import com.eelpo.common.util.BlankUtils;

/**
 * 是和否的状态枚举对象
 * 
 * @author <a href="mailto:Brian@eelpo.com">汪洪州</a>
 * @since 1.0
 */
public enum YesOrNo {
	/**
	 * 实例
	 */
	YES(Boolean.TRUE, "是"), NO(Boolean.FALSE, "否"), ALL(null, "全部");

	/**
	 * 枚举值
	 */
	private Boolean value;

	/**
	 * 枚举文本标签
	 */
	private String label;

	/**
	 * 构造函数，必须私有，不允许实例化
	 * 
	 * @param value
	 *            枚举值
	 * @param label
	 *            枚举文本标签
	 */
	private YesOrNo(Boolean value, String label) {
		this.value = value;
		this.label = label;
	}

	public Boolean getValue() {
		return value;
	}

	public String getLabel() {
		return label;
	}

	public static YesOrNo valueOf(Boolean value) {
		return value ? YES : NO;
	}

	public static Boolean valueOf(YesOrNo yesOrNo) {
		if (BlankUtils.isBlank(yesOrNo)) {
			return null;
		}

		return yesOrNo.getValue();
	}
}
